<%#
 Copyright 2013-2020 the original author or authors from the JHipster project.

 This file is part of the JHipster project, see https://www.jhipster.tech/
 for more information.

 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

      http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-%>
# ConfigMap template.
#
# This is centralized/externalized configuration service from OpenShift. Pls note wherever displayName says
# *** PLEASE DO NOT CHANGE THIS ***, don't touch that as those parameters will be referenced in other places.
#
apiVersion: <%= KUBERNETES_CORE_API_VERSION  %>
kind: Template
metadata:
  name: application-config-template
  namespace: <%= openshiftNamespace %>
  annotations:
    description: This template defines the config objects
    tags: "config, key/value"
    openshift.io/display-name: application-config-template
    openshift.io/long-description: "This template provides the config objects"
    openshift.io/provider-display-name: JHipster-OpenShift
labels:
  app: application-config-template
  createdBy: JHipster-Team
parameters:
  -
    name: APPLICATION_NAME
    value: application-config
    description: Name of the resource
    required: true
    displayName: "*** PLEASE DO NOT CHANGE THIS ***"
objects:
  -
    apiVersion: <%= KUBERNETES_CORE_API_VERSION  %>
    kind: ConfigMap
    metadata:
      name: ${APPLICATION_NAME}
    #common configuration shared between all applications
    data:
      application.yml: |-
        configserver:
          name: <% if (serviceDiscoveryType === 'eureka') { %> JHipster Registry<% } %><% if (serviceDiscoveryType === 'consul') { %>Consul<% } %>
          status: Connected to <% if (serviceDiscoveryType === 'eureka') { %>the JHipster Registry<% } %><% if (serviceDiscoveryType === 'consul') { %>Consul<% } %> running in OpenShift
        <%_ if (serviceDiscoveryType === 'eureka') {  _%>
        eureka:
          client:
            initial-instance-info-replication-interval-seconds: 15
            instance-info-replication-interval-seconds: 15
            registry-fetch-interval-seconds: 15
            fetch-registry: true
            register-with-eureka: true
            eureka-service-url-poll-interval-seconds: 15
          instance:
            lease-renewal-interval-in-seconds: 10
            registry-default-open-for-traffic-count: 0
        <%_ } _%>
        jhipster:
          security:
            authentication:
              jwt:
                base64-secret: <%= jwtSecretKey %>
      # app specific configuration
      <%_ if (serviceDiscoveryType === 'eureka') {  _%>
      jhipster-registry.yml: |-
        eureka:
          client:
            service-url:
              # This must contain a list of all Eureka server replicas for registry HA to work correctly
              defaultZone: <% for (let i = 0; i < registryReplicas; i++) { %>http://admin:${SPRING_SECURITY_USER_PASSWORD}@jhipster-registry-<%- i %>.jhipster-registry:8761/eureka/<% if (i < registryReplicas-1) { _%>,<% }} %>
      <%_ } _%>
